package com.topdt.jbpm.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thx.common.service.BaseManager;
import com.topdt.jbpm.dao.AppAuthorityDao;
import com.topdt.jbpm.model.AppAuthority;
import com.topdt.jbpm.model.Application;

/**
 * 
 * 建立日期 : 2014-11-7 上午11:26:18<br>
 * 作者 : zhangyong<br>
 * 模块 : <br>
 * 描述 : <br>
 * 修改历史: 序号 日期 修改人 修改原因 <br>
 * 1 <br>
 * 2 <br>
 */
@Service
@Transactional(readOnly = true)
public class AppAuthorityService extends BaseManager<AppAuthority>{
	
	@Autowired
	private AppAuthorityDao appAuthorityDao;
	
	/**
	 * 
	 * @author zhangyong
	 * @date   2014-11-7 下午02:40:23 
	 * @param appId
	 */
	@Transactional(readOnly = false)
	public void deleteByAppId(String appId){
		appAuthorityDao.deleteByAppId(appId);
	}
	
	/**
	 * 
	 * @author zhangyong
	 * @date   2014-11-7 下午02:53:14 
	 * @param appId
	 * @return
	 */
	public List<AppAuthority>  findByAppId(String appId){
		return appAuthorityDao.findByAppId(appId);
	}
	
	/**
	 * 
	 * @author zhangyong
	 * @date   2014-11-7 下午05:25:14 
	 * @param appId
	 * @return
	 */
	public Map <String ,AppAuthority> getAuthorityMapByAppId(String appId){
		List<AppAuthority>  authorityList  =  appAuthorityDao.findByAppId(appId);
		Map <String ,AppAuthority> authorityMap = new HashMap<String ,AppAuthority>();
		for(AppAuthority authority  :authorityList){
			authorityMap.put(authority.getAuthorityType(),authority);
		}
		return authorityMap;
	}
}
